namespace FadeLang.CstVisitor
{
    public class NumberVisitor : FadeLangBaseVisitor<dynamic>
    {
        private static NumberVisitor instance;
        public static NumberVisitor Instance => instance ?? (instance = new NumberVisitor());

        public override dynamic VisitNumber(FadeLangParser.NumberContext context) {
            if (context.INT() != null || context.HEX() != null) {
                return int.Parse(context.GetText());
            }
            if (context.FLOAT() != null || context.HEX_FLOAT() != null) {
                return double.Parse(context.GetText());
            }
            return base.VisitNumber(context);
        }
    }
}